﻿#pragma strict

var cam:Camera;
var agent:NavMeshAgent;

function Start () {
	agent = GetComponent.<NavMeshAgent>();
	cam = Camera.main;
}

function Update () {
	if(Input.GetMouseButtonDown(0)){
		var ray:Ray = cam.ScreenPointToRay(Input.mousePosition);
		var hit:RaycastHit;
		if(Physics.Raycast(ray,hit)){
			agent.destination = hit.point;
		}
	}
}